package tech.xs.common.sys.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import tech.xs.common.framework.domain.annotations.Dict;
import tech.xs.common.framework.domain.annotations.DictData;
import tech.xs.common.framework.domain.constant.ModuleNames;
import tech.xs.common.framework.domain.enums.BaseEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * 账户状态
 *
 * @author 沈家文
 * @since 2023/6/21 16:47
 */
@Dict(code = "AccountStatus", name = "账户状态", module = ModuleNames.COMMON)
public enum SysAccountStatusEnum implements BaseEnum {

    /**
     * 禁用
     */
    @DictData(name = "禁用", order = 20)
    DISABLE(0),

    /**
     * 正常
     */
    @DictData(name = "正常", order = 10)
    NORMAL(1);


    @EnumValue
    @JsonValue
    private final int value;

    private static final Map<Integer, SysAccountStatusEnum> mappings = new HashMap<>(values().length);

    static {
        for (SysAccountStatusEnum item : values()) {
            mappings.put(item.getValue(), item);
        }
    }

    SysAccountStatusEnum(int value) {
        this.value = value;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static SysAccountStatusEnum create(int value) {
        return mappings.get(value);
    }


    @Override
    public Integer getValue() {
        return value;
    }
}
